/**
 * @Author: wangjian
 * 656876071@qq.com
 * @Date: ${.now}
 * @LastEditTime: ${.now}
 * @FilePath: src/views/system/api/${dto.className}Api.ts
 * @Description:
 */
import r from '@/core/utils/request'

export interface ${dto.className} {
    <#list dto.fields as field>
         ${field.fieldName}? : string;
    </#list>

    [key:string]:any
}

export default () => {
    return {
        getPage: ({params: queryParams = {}, current = 1, size = 10}) => {
            return r.get('${controller.rootPath}/page', {
                params: {
                    current,
                    size,
                    ...queryParams
                }
            })
        }
        ,
        getById: (id: string) => {
            return r.get(`${controller.rootPath}/${r'${id}'}`)
        },
        add:
            (rawObject: ${dto.className}) => {
                return r.post('${controller.rootPath}', rawObject)
            },
        update:
            (rawObject: ${dto.className}) => {
                return r.put(`${controller.rootPath}`, rawObject)
            }
            ,
        deleteById:
            (id: string) => {
                return r.delete(`${controller.rootPath}/${r'${id}'}`)
            },
    }
}